<?php

namespace App\Models;


use App\Libs\DataFormat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;


class FeelingLike extends Model
{
    use DataFormat;

    protected  $table='feeling_tone_like';

    public static  $formatKey = ['id'=>'int', 'created_at'=>'string', 'feeling_id'=>'int',  ];

    public function feeling()
    {
        return $this->hasOne('App\Models\Feeling', 'id', 'feeling_id');
    }

    public function user()
    {
        return $this->hasOne('App\Models\User', 'id', 'user_id');
    }

    public function getAllInfo()
    {
        $data = FeelingLike::format($this);
        $data['feeling_is_display'] = $this->feeling->is_display;
        $data['is_like'] = 1;
        $data['user_info'] = $this->user->getUserAvatar();
        if(!empty($this->parent))
        {
            $data['comment_to'] = $this->parent->user->getUserAvatar();
        }


        return $data;
    }

}
